import axios from "axios";
axios.defaults.baseURL="http://42.194.149.226:8899/";
export default {
    //获取用户信息
    async getUserInfo(pagesize, currentPage,queryString) {
        let param = {
            pageSize: pagesize, 
            currentPage: currentPage, 
            queryString: queryString
        }
        return axios
            .post(`admin/list`, param).then(function (response) {
                return new Promise((resolve) => {
                    resolve(response.data);
                  //  console.log(response);
                });
            })
            .catch(function (error) {
                console.log(error);
            });
    },

    //获取文件列表
    async getFiles(pagesize, currentPage,queryString) {
        let param = {
            pageSize: pagesize, 
            currentPage: currentPage, 
            queryString: queryString
        }
        return axios
            .post(`admin/filelist`,param).then(function (response) {
                return new Promise((resolve) => {
                    resolve(response.data);
                 //   console.log(response.data);
                });
            })
            .catch(function (error) {
                console.log(error);
            });
    },

    //获取不同科目文件列表
    async getCourseFiles(sname) {
        return axios
            .get(`user/subjectfiles`, { params: { sname: sname } }).then(function (response) {
                return new Promise((resolve) => {
                    resolve(response.data);
                    //console.log(response.data);
                });
            })
            .catch(function (error) {
                console.log(error);
            });
    },
    //删除用户
    async delUser(id) {
        return axios
            .get(`admin/deluser?id=` + id).then(function (response) {
                return new Promise((resolve) => {
                    resolve(response);
                  //  console.log(response);
                });
            })
            .catch(function (error) {
                console.log(error);
            });
    },

    //删除文件
    async delFile(id) {
        return axios
            .get(`user/deldoc`, { params: { id: id } }).then(function (response) {
                return new Promise((resolve) => {
                    resolve(response);
                  //  console.log(response);
                });
            })
            .catch(function (error) {
                console.log(error);
            });
    },

    //添加用户
    async addUser(data) {
        return axios
            .post(`admin/adduser`, data).then(function (response) {
                return new Promise((resolve) => {
                    resolve(response);
                    console.log(response);
                });
            })
            .catch(function (error) {
                console.log(error);
            });
    },

}